/*
 * File:   Shell.h
 * Author: henrya
 *
 * Created on June 13, 2009, 6:58 PM
 */

#ifndef _SHELL_H
#define	_SHELL_H
#include <pthread.h>
#include <string>
#include "Mailer.h"
#include "SynchronizedQueue.h"
#include "MultiLevelScheduler.h"
using std::string;

class MultiLevelScheduler;
class Shell {
private:
    pthread_t self;
    volatile bool interupted;
    Mailer* mailer;
    SynchronizedQueue<string*> toPrint;
    Network* network;
    bool sleeping;
    pthread_mutex_t classLock;
    pthread_cond_t classCond;
public:
    Shell();
    virtual ~Shell();
    void start();
    void join();
    void interrupt();
    void run();
    void print(string* s);

    void wakeUp();
private:
    void doCreateNet(string* filename);
    void goToSleep();
    void privateWakeUp(bool continueSleeping);
};

#endif	/* _SHELL_H */

